'
' DotNetNukeŽ - http://www.dotnetnuke.com
' Copyright (c) 2002-2006
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
'
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml
Imports System.Security
Imports System.IO
Imports System.Globalization

Namespace DotNetNuke.Modules.IWeb

    <WebService(Namespace:="http://webservices.DotNetNuke.com/")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Public Class WebService
        Inherits System.Web.Services.WebService

        Private _IWebCredentials As IWebAuthendicationHeader

        Public Property IWebCredentials() As IWebAuthendicationHeader
            Get
                Return _IWebCredentials
            End Get
            Set(ByVal Value As IWebAuthendicationHeader)
                _IWebCredentials = Value
            End Set
        End Property

        Public Sub New()
            MyBase.New()
        End Sub

        ''' <summary>
        ''' Retrieves Portals on Server
        ''' </summary>
        ''' <returns>Portals</returns>
        <WebMethod(Description:=" Retrieves Portals on Server *DotNetNuke* |IWEB Core| #General# !Portal! "), SoapHeader("IWebCredentials")> _
        Public Function PortalsOnServer() As String
            Dim strResponse As String = ""
            Try
                Dim objIWebAuthendication As New IWebAuthendication(IWebCredentials)
                If Not objIWebAuthendication.ValidAndAuthorized() Then
                    Return "Not Authorized"
                End If

                Dim arrPortals As ArrayList
                Dim colPortalInfo As New PortalInfo()
                Dim colPortalController As New PortalController()
                arrPortals = colPortalController.GetPortals()

                Dim i As Integer
                For i = 0 To (arrPortals.Count - 1)
                    colPortalInfo = CType(arrPortals(i), PortalInfo)
                    strResponse = strResponse & colPortalInfo.PortalID & "," & colPortalInfo.PortalName & ","
                Next i

                strResponse = strResponse.Substring(0, strResponse.Length - 1)
            Catch ex As Exception
                strResponse = ex.Message
            End Try

            Return strResponse
        End Function

    End Class
End Namespace